<template>
	<view style="position: relative;height: 99.5vh;box-sizing: border-box;padding: 100rpx 0 0;">
		<view class="flex_center" style="height: 80rpx;">
			输入验证码
		</view>
		<password-input :numLng='password' style="margin: 400rpx auto 0;width: 85%;"></password-input>
		<number-keyboard  ref='KeyboarHid' @input='getnum' psdLength='6'>123</number-keyboard>
	</view>
</template>

<script>
	import numberKeyboard from '@/components/number-keyboard/number-keyboard.vue'
	import passwordInput from '@/components/password-input/password-input.vue'
	export default {
		data() {
			return {
				 password: "",
				 phone:''
			};
		},
		components:{
			numberKeyboard,passwordInput
		},
		onLoad(e){
			this.phone = e.phone
		},
		methods:{
			getnum(e){
				this.password = e
				if(e.length == 6){
					if(!parseInt(this.phone).length == 11){
						uni.showToast({
							title:'验证失败，请重新'
						})
					}
					uni.showLoading({
						title:'验证中'
					})
					this.$ajax('/user/bindMobileByVerifyCode',{mobile:this.phone,verifyCode:e},'post').then(res => {
						const item = res.data.obj
						let temp = ''
						if (item.update && item.task.finish === 1) {
							temp = '?hasTaskComplate=true'
						}
						uni.setStorageSync('token', item.token)
						uni.hideLoading()
						uni.reLaunch({
							url:`../index/index${temp}`
						})
					})
				}
			}
		}
	}
</script>

<style lang="less">

</style>
